/**
 * 分页显示数据表格，具有分页显示数据、排序、设置分页大小功能
 */
Ext.namespace("Ext.ux.grid");

Ext.ux.grid.YwGrid = Ext.extend(Ext.grid.GridPanel, {
  // 表格结构
  structure: null,
  // 关键字段
  keyField: null,
  
  tplcode: null,
  
  // 获取数据的URL
  url: '',
  dblurl: '',
  dblparams: [],
  dblwin: null,
  // 默认排序字段
  defaultSortField: '',
  // 是否需要分页工具栏，默认为true
  needPage: true,
  // 是否需要显示工具栏
  needTbar: true,
  
  // -------------------------------------
  needPrintTbar: false,
  needPrintBtn: false,
  needPrintdblclick: false,
  
  needYslBtn: false,
  
  needSelectTbar: false,
  needPrintRqjyxkzBtn: false,
  needPrintRqjyxkzfbBtn: false,
  needPrintZzzsBtn: false,
  needPrintZzzsfbBtn: false,
  needPrintHwggBtn: false,
  needPrintGyssxkbsBtn: false,
  needCsdlwjSelectTbar:false,//城市道路挖掘的选择企业框--查询
  // -------------------------------------
  needSelect4CsdlwjTbar:false,     //智能表单 城市道路挖掘

  // 预加载数据
  preload: true,
  
  // 是否显示分页信息
  showPageInfo: true,
  
  // 每页记录数
  pageSize: 15,
  
  // 是否显示加载提示
  loadMask: true,
  
  // 是否显示边框
  frame: false,
  
  iconScale: 'medium',

  stripeRows: true,
  columnLines: true,
  
  // 查询工具栏
  toolbar: {},
  
  viewConfig: {
    forceFit: true
  },
  
  // 组件初始化
  initComponent: function(){
    if(this.structure != null){
      this.initStructure(); // 根据表格结构构造ColumnModel对象和Record对象
    }   
    Ext.ux.grid.YwGrid.superclass.initComponent.call(this);
  },

  // 根据表格结构构造ColumnModel对象、Record对象、Store对象等
  initStructure: function(){
    if (this.needTbar) {
	    this.tbar = new Ext.Toolbar();
	    
      // -------------------------------------
	    if (this.needPrintTbar) this.printTbar();
	  if(this.needPrintRqjyxkzBtn) this.printRqjyxkzBtn();
	  if(this.needPrintRqjyxkzfbBtn) this.printRqjyxkzfbBtn();
	  if(this.needPrintZzzsBtn) this.printZzzsBtn();
	  if(this.needPrintZzzsfbBtn) this.printZzzsfbBtn();
	  if(this.needPrintHwggBtn) this.printHwggBtn();
	  if(this.needPrintGyssxkbsBtn) this.printGyssxkbsBtn();
      if (this.needPrintBtn) this.printBtn();
      // -------------------------------------
      if (this.needYslBtn) this.yslBtn();
      
      if (this.needSelectTbar) this.selectTbar();
      if (this.needCsdlwjSelectTbar) this.csdlwjSelectTbar();
      //--------------------------------------
      
      
      //-----------------城市道路挖掘申请---------------------
      if(this.needSelect4CsdlwjTbar)this.select4CsdlwjTbar();
      
	  }

    var oColModel = new Array();
    var oRecord = new Array();

    oColModel[0] = new Ext.grid.RowNumberer();

    // 构造GRID所需对象
    for(var i=0, len=this.structure.length; i<len; i++){
      // 表格结构的列定义
      var column = this.structure[i];
      
      oColModel[oColModel.length] = {
        header: column.header,
        dataIndex: column.name,
        hidden: column.hidden == null ? false : column.hidden,
        width: column.width == null ? 50 : column.width,
        sortable: column.sortable,
        renderer: column.type == 'date' ? util.Format.dateRenderer('Y-m-d') : Ext.grid.ColumnModel.defaultRenderer
      };
      
      oRecord[oRecord.length] = {
        name: column.name
      };
    }
    
    this.sm = new Ext.grid.RowSelectionModel({singleSelect:false});
    // 构造columnModel
    this.cm = new Ext.grid.ColumnModel(oColModel);
    this.colModel = this.cm;
    
    // 默认可排序
    this.cm.defaultSortable = true;
    
    // 构造记录对象和reader对象
    var record = Ext.data.Record.create(oRecord);
    var reader = new Ext.data.JsonReader({
      totalProperty: 'totalCount',
      root: 'result',
      id: this.keyField
    }, record);
    
    // 构造store对象
    this.ds = new Ext.data.GroupingStore({
      proxy: new Ext.data.HttpProxy({
        url: ctx + this.url
      }),
      reader: reader,
      sortInfo: {
        field: this.defaultSortField,
        direction: 'ASC'
      },
      remoteSort: true
    });
    this.store = this.ds;
    
    // 添加分页工具栏  
    if (this.needPage){
      var pagingToolbar = new Ext.PagingToolbar({
        store: this.ds,
        pageSize: this.pageSize,
        displayInfo: true,
        displayMsg: '第 {0} - {1} 条记录 / &nbsp;共 {2} 条记录',
        emptyMsg: '<font color="red">提示：没有任何符合条件的记录！</font>'
      });
      this.bbar = pagingToolbar;
      this.bottomToolbar = this.bbar;
    }
      
    this.on('rowdblclick', function(grid){
      if (this.needPrintdblclick)
        this.printdblclick();
      else if (this.needSelectTbar)
        this.selectDblclick();
      else if(this.needSelect4CsdlwjTbar)
      	this.selectDW();
      else
      	this.dblclick();
    }, this);
    
    // 加载数据列表
    if(this.preload) this.store.load({params:{start:0, limit:this.pageSize}});
  },
 
  dblclick: function () {
    var sel = this.getSelectionModel().getSelections();
    if(sel.length == 0) {
      Ext.Msg.alert('系统提示', '你没有选中任何记录，请重新选择！'); return;
    }
    if(sel.length > 1) {
      Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！'); return;
    }
    var dblurl = this.dblurl;
    for (var i = 0; i < this.dblparams.length; i++) {
      if (dblurl.indexOf('?') < 0) dblurl += '?'; else dblurl += '&';
      dblurl += this.dblparams[i] + '=' + sel[0].get(this.dblparams[i]);
    }
    var params = {url: ctx + dblurl};
    if (this.dblwin) {
      params.w = this.dblwin.w;
      params.h = this.dblwin.h;
    }
    
    YwUtil.openMaxsizeWin(params);
  },
 
  printdblclick: function () {
    var sel = this.getSelectionModel().getSelections();
    if(sel.length == 0) {
      Ext.Msg.alert('系统提示', '你没有选中任何记录，请重新选择！'); return;
    }
    if(sel.length > 1) {
      Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！'); return;
    }
    var dblurl = '';
    
    if ('rqssgd' == this.templateCode) {
      dblurl = '/yw-rq-ssgd-sqb!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if ('rqssgdqx' == this.templateCode) {
      dblurl = '/yw-rq-ssgd-sqb-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    } else if ('rqrsqjazwxqyzz' == this.templateCode) {
      dblurl = '/yw-rq-qyzz-info!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    } else if ('rqrsqjazwxqyzzqx' == this.templateCode) {
      dblurl = '/yw-rq-qyzz-info-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('hwggshsqb' == this.templateCode){
      dblurl = '/yw-hw-sh-sqb!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('zzgqba' == this.templateCode){
      dblurl = '/yw-rq-zzgqba!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('rqjyxkz_pzqy' == this.templateCode){
      dblurl = '/yw-rq-qyjyxkpz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('rqjyxkz_gdqy' == this.templateCode){
      dblurl = '/yw-rq-qyjyxkgd!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('rqjyxkzqx_pzqy' == this.templateCode){
      dblurl = '/yw-rq-qyjyxkpz-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('rqjyxkzqx_gdqy' == this.templateCode){
      dblurl = '/yw-rq-qyjyxkgd-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('jzljzyz_xzfz' == this.templateCode){//建筑废弃物准运证==>新增发证
      dblurl = '/yw-yn-ljzyz-sqb!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljzyz_nsxz' == this.templateCode){//建筑废弃物准运证==>年审续证
      dblurl = '/yw-yn-ljzyz-nsxz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljzyz_clbf' == this.templateCode){//建筑废弃物准运证==>车辆报废
      dblurl = '/yw-yn-ljzyz-clbf!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljzyz_ghhz' == this.templateCode){//建筑废弃物准运证==>过户换证
      dblurl = '/yw-yn-ljzyz-ghhz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljzyz_shhz' == this.templateCode){//建筑废弃物准运证==>损坏换证
      dblurl = '/yw-yn-ljzyz-shhz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljzyz_ysbb' == this.templateCode){//建筑废弃物准运证==>遗失补办
      dblurl = '/yw-yn-ljzyz-ysbb!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczz_xzfz' == this.templateCode){//建筑废弃物处置证(运输)==>新增发证
      dblurl = '/yw-yn-jzfqwczc-jbxx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('jzljczz_shhz' == this.templateCode){//建筑废弃物处置证(运输)==>损坏换证
      dblurl = '/yw-yn-jzfqwczc-shhz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczz_nsxz' == this.templateCode){//建筑废弃物处置证(运输)==>年审续证
      dblurl = '/yw-yn-jzfqwczc-nsxz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczz_bghz' == this.templateCode){//建筑废弃物处置证(运输)==>变更换证
      dblurl = '/yw-yn-jzfqwczc-bghz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczz_ysbb' == this.templateCode){//建筑废弃物处置证(运输)==>遗失补办
      dblurl = '/yw-yn-jzfqwczc-ysbb!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczz' == this.templateCode){//建筑废弃物处置证(排放、收纳)
      dblurl = '/yw-yn-jzfqwczz-pfsn!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('csdlwj' == this.templateCode){//道路挖掘
      dblurl = '/smart-form-csdlwj!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('csdlwjqx' == this.templateCode){//区县道路挖掘
      dblurl = '/smart-form-csdlwj!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('csdllszysp' == this.templateCode){//道路占用
      dblurl = '/dllszy!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('csdllszyspqx' == this.templateCode){//区县道路占用
      dblurl = '/dllszy!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('ccgbggcs' == this.templateCode){ //拆除公共厕所
      dblurl = '/ggcs!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('shljqssj' == this.templateCode){ //从事陆域城市生活垃圾经营性清扫、收集、运输服务许可审批
      dblurl = '/smart-form-shljqs!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('shljcz' == this.templateCode){ //从事城市生活垃圾经营性处置服务许可审批
      dblurl = '/csshlj-cz!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('shljys' == this.templateCode){ //从事水域城市生活垃圾经营性清扫、收集、运输服务许可审批
      dblurl = '/shlj-ys!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxn_xz' == this.templateCode){ //消纳
      dblurl = '/yw-yn-jzfqwczz-xn!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxn_yq' == this.templateCode){ //消纳延期
      dblurl = '/yw-yn-jzfqwczz-xnyq!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpf_yq' == this.templateCode){ //排放延期
      dblurl = '/yw-yn-jzfqwczz-pfsnyq!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpf_bg' == this.templateCode){ //排放变更
      dblurl = '/yw-yn-jzfqwczz-pfsnbg!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpf_xz' == this.templateCode){ //排放新增
      dblurl = '/yw-yn-jzfqwczz-pfsn!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxn_bg' == this.templateCode){ //消纳变更
      dblurl = '/yw-yn-jzfqwczz-xnbg!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczzqx_xzfz' == this.templateCode){//区建筑废弃物处置证(运输)==>新增发证
      dblurl = '/yw-yn-jzfqwczc-jbxx-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId');
    }else if('jzljczzqx_shhz' == this.templateCode){//区建筑废弃物处置证(运输)==>损坏换证
      dblurl = '/yw-yn-jzfqwczc-shhz-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczzqx_nsxz' == this.templateCode){//区建筑废弃物处置证(运输)==>年审续证
      dblurl = '/yw-yn-jzfqwczc-nsxz-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczzqx_bghz' == this.templateCode){//区建筑废弃物处置证(运输)==>变更换证
      dblurl = '/yw-yn-jzfqwczc-bghz-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzljczzqx_ysbb' == this.templateCode){//区建筑废弃物处置证(运输)==>遗失补办
      dblurl = '/yw-yn-jzfqwczc-ysbb-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxnqx_xz' == this.templateCode){ //消纳新增区
      dblurl = '/yw-yn-jzfqwczz-xn-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxnqx_yq' == this.templateCode){ //消纳延期
      dblurl = '/yw-yn-jzfqwczz-xnyq-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzxnqx_bg' == this.templateCode){ //消纳变更
      dblurl = '/yw-yn-jzfqwczz-xnbg-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpfqx_yq' == this.templateCode){ //排放延期
      dblurl = '/yw-yn-jzfqwczz-pfsnyq-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpfqx_bg' == this.templateCode){ //排放变更区
      dblurl = '/yw-yn-jzfqwczz-pfsnbg-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }else if('jzfqwczzpfqx_xz' == this.templateCode){ //排放新增区
      dblurl = '/yw-yn-jzfqwczz-pfsn-qx!printcz.action?id='+this.fkid + '&templateCode=' + this.templateCode + '&fileCode=' + sel[0].get('fileCode') + '&taskInstDbid=' + this.taskInstDbid + '&templateId=' + sel[0].get('templateId'); 
    }
   
    var params = {url: ctx + dblurl};
    
    YwUtil.openMaxsizeWin(params);
  },
  
  hadPrintd: function () {
    var sel = this.getSelectionModel().getSelections();
    if(sel.length == 0) {
      Ext.Msg.alert('系统提示', '你没有选中任何记录，请重新选择！'); return;
    }
    if(sel.length > 1) {
      Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！'); return;
    }
  	var templateCode = sel[0].get('templateCode');
  	var url = '';
  	if('rqssgd' == templateCode){
  		url = '${ctx}/yw-rq-ssgd-sqb!changeSendAcceptNoticeOrSendNoticeById.action';
  	}else if('rqrsqjazwxqyzz' == templateCode){
  		url = '${ctx}/yw-rq-qyzz-info!changeSendAcceptNoticeOrSendNoticeById.action';
  	}else if('rqjyxkz_pzqy' == templateCode || 'rqjyxkz_gdqy' == templateCode ){ 
  		url = '${ctx}/yw-rq-qyjyxkgd!changeSendAcceptNoticeOrSendNoticeById.action';
  	}
    //外面的可以了
    Ext.Ajax.request({
				url: url,
				dataType: 'xml',//数据类型设置
				params:{
					'id':sel[0].get('id'),
					'sendAcceptNotice':sel[0].get('sendAcceptNotice'),
					'sendYqNotice':sel[0].get('sendYqNotice'),
					'templateCode':sel[0].get('templateCode')
				},
				success:function(response){
					this.search();//刷新一下列表
				},
				failure:function(){
				},
				scope: this
	});

	/*
	var sendAcceptNotice = this.sendAcceptNotice;
  	var sendYqNotice = this.sendYqNotice;
  	var id =this.fkid; 
  	if(sendAcceptNotice !='1'){
		sendAcceptNotice='0';
  	}
  	
  	if(sendYqNotice !='1'){
		sendYqNotice='0';
  	}
	Ext.Ajax.request({
				url:'${ctx}/yw-rq-ssgd-sqb!changeSendAcceptNoticeOrSendNoticeById.action',
				dataType: 'xml',//数据类型设置
				params:{
					'id':id,
					'sendAcceptNotice':sendAcceptNotice,
					'sendYqNotice':sendYqNotice
				},
				success:function(response){
					parent.search();//刷新一下列表
				},
				failure:function(){
				},
				scope: this
	});
	*/
	
    //var u = '/yw-rq-ssgd-sqb!changeSendAcceptNoticeOrSendNoticeById.action?id='+sel[0].get('id') + '&sendAcceptNotice=' + sel[0].get('sendAcceptNotice') + '&sendYqNotice=' + sel[0].get('sendYqNotice');
    //var params = {url: ctx + u};
    //YwUtil.abc(params);
    
  },
  
  //=============智能表单修改（城市道路挖掘）开始======================
  selectDW:function(){
  	 var sel = this.getSelectionModel().getSelections();
  	 if(sel.length == 0){
  	 	Ext.Msg.alert("系统提示","你没有选中任何记录，请重新选择！");
  	 }else if(sel.length >1){
  	 	Ext.Msg.alert("系统提示","只能选择一条记录，请重新选择！");
  	 }else{
  	 	var params = {
            r: sel[0],
            tplcode: this.tplcode
     };
     var obj = Ext.getCmp('selectQyxxWin');
     var otherObj = Ext.getCmp('selectSgdwWin');
     var selectQyxxTwo = Ext.getCmp('selectQyxxTwo');
     var selectYsgs = Ext.getCmp('selectYsgs');
     if(obj){
     	if(selectDlwjCallback)
     		selectDlwjCallback(params);
     	obj.close();
     }
     if(otherObj){
     	if(selectDlwjJsdwCallback)
     		selectDlwjJsdwCallback(params);
     	otherObj.close();
     }
     if(selectQyxxTwo){
     	if(selectQyxxTwoCallback)
     		selectQyxxTwoCallback(params);
     	selectQyxxTwo.close();
     }
     if(selectYsgs){
     	if(selectYsgsCallback)
     		selectYsgsCallback(params);
     	selectYsgs.close();
     }
    }
  },
  
select4CsdlwjTbar:function(){
  	 this.toolbar.search_sqdw = new Ext.form.TextField({
     	width: 150,
     	emptyText: '请输入'
    });
    
    this.tbar.addItem('-');
    this.tbar.addItem({
		text: '选择',
		iconCls: 'icon_yes',
		scale: this.iconScale,
		handler: function(){
			this.selectDW();
	    },
	   	scope: this
    });
    
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '关闭',
      iconCls: 'icon-middle-cancel',
      scale: this.iconScale,
      handler: function(){
      	var obj = Ext.getCmp('selectQyxxWin');
      	var otherObj = Ext.getCmp('selectSgdwWin');
      	var selectQyxxTwo = Ext.getCmp('selectQyxxTwo');
      	var selectYsgs = Ext.getCmp('selectYsgs');
      	if(obj)
      		obj.close();
      	if(otherObj)
      		otherObj.close();
      	if(selectQyxxTwo)
      		selectQyxxTwo.close();
      	if(selectYsgs)
      		selectYsgs.close();
      },
      scope: this
    });
    
    this.tbar.addItem('-');
    this.tbar.addItem('单位：');
    this.tbar.addItem(this.toolbar.search_sqdw);
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '查询',
      iconCls: 'icon-find',
      scale: this.iconScale,
      handler: function(){
        this.search();
      },
      scope: this
    });
     this.tbar.addItem('-');
  	
  },
   //=============智能表单修改（城市道路挖掘）结束======================
    
  selectDblclick: function () {
    var sel = this.getSelectionModel().getSelections();
    if(sel.length == 0) {
      Ext.Msg.alert('系统提示', '你没有选中任何记录，请重新选择！'); return;
    }
    if(sel.length > 1) {
      Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！'); return;
    }
    var params = {
      r: sel[0],
      tplcode: this.tplcode
    };
    if (selectCallback) selectCallback(params);
        if(selectJsdwCallback) 
    {
      selectJsdwCallback(params);
      if(Ext.getCmp('selectJsdwWin'))
     Ext.getCmp('selectJsdwWin').hide();
    }
     if(selectSgdwCallback) 
    {
     selectSgdwCallback(params);
     if(Ext.getCmp('selectSgdwWin'))
     Ext.getCmp('selectSgdwWin').hide();
    }
    if(Ext.getCmp('selectQyxxWin'))
    Ext.getCmp('selectQyxxWin').hide();
  },
  
  thclick: function () {
    var sel = this.getSelectionModel().getSelections();
    if(sel.length == 0) {
      Ext.Msg.alert('系统提示', '你没有选中任何记录，请重新选择！'); return;
    }
    if(sel.length > 1) {
      Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！'); return;
    }
  },
  
  search: function(){
    this.store.load({params:{start: 0, limit:this.pageSize}});
  },
  
  reset: function () {
    for (key in this.toolbar) {
      if (this.toolbar[key] && this.toolbar[key].setValue) this.toolbar[key].setValue('');
    }
    this.search();
  },
  
  printTbar: function () {
    this.toolbar.search_acceptNo = new Ext.form.TextField({
      width: 100,
      emptyText: '请输入受理号'
    });
    this.toolbar.search_topic = new Ext.form.TextField({
      width: 200,
      emptyText: '请输入你要查询的单位'
    });
    this.toolbar.search_topid = new Ext.form.ComboBox({
      store         : new Ext.data.SimpleStore({
        fields      : ['value', 'view'],
        data        : [[1, '燃气设施改动'],[2, '燃气企业资质审批'],
        				[3, '户外广告设置审批'],[4, '燃气经营许可证审批==>管道燃气企业'],
        				[5, '燃气经营许可证审批==>液化气企业'],
        				[7, '城市道路人行道及相关公共场地挖掘审批'],[6, '城市道路人行道及相关公共场地临时占用审批']]
      }),
      width         : 280,
      editale       : true,
      emptyText     : '请选择审批项目列别',
      displayField  : 'view',
      valueField    : 'value',
      mode          : 'local',
      triggerAction : 'all',
      listeners     : {
        select    : function (combo, record, index) { }
      }
    });
    
    this.tbar.addItem('-');
    this.tbar.addItem('受理号：');
    this.tbar.addItem(this.toolbar.search_acceptNo);
    this.tbar.addItem('-');
    this.tbar.addItem('单位：');
    this.tbar.addItem(this.toolbar.search_topic);
    this.tbar.addItem('-');
    //this.tbar.addItem('审批项目类别：');
   // this.tbar.addItem(this.toolbar.search_topid);
    //this.tbar.addItem('-');
    this.tbar.addItem({
      text: '查询',
      iconCls: 'icon-find',
      scale: this.iconScale,
      handler: function(){
        this.search();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '重置',
      iconCls: 'icon-reset',
      scale: this.iconScale,
      handler: function(){
        this.reset();
      },
      scope: this
    });
	var hadprintflag = this.hadprintflag;
    if(1==hadprintflag){//判断是否要显示 [已打印] 按钮
    	this.tbar.addItem('-');
    	this.tbar.addItem({
	      text: '已打印',
	      iconCls: 'icon-print',
	      scale: this.iconScale,
	      handler: function(){
	      	var aa = this.hadPrintd(); 
		    //this.search();
	      },
	      scope: this
	    });
    }
    
    this.tbar.addItem('-');
  },
  selectTbar: function () {
    this.toolbar.search_sqdw = new Ext.form.TextField({
      width: 150,
      emptyText: '请输入你要查询的单位'
    });
    
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '选择',
      iconCls: 'icon_yes',
      scale: this.iconScale,
      handler: function(){
        this.selectDblclick();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '关闭',
      iconCls: 'icon-middle-cancel',
      scale: this.iconScale,
      handler: function(){
        Ext.getCmp('selectQyxxWin').hide();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem('->');
    this.tbar.addItem('-');
    this.tbar.addItem('单位：');
    this.tbar.addItem(this.toolbar.search_sqdw);
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '查询',
      iconCls: 'icon-find',
      scale: this.iconScale,
      handler: function(){
        this.search();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '重置',
      iconCls: 'icon-reset',
      scale: this.iconScale,
      handler: function(){
        this.reset();
      },
      scope: this
    });
    this.tbar.addItem('-');
  },
  csdlwjSelectTbar: function () {
        
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '选择',
      iconCls: 'icon_yes',
      scale: this.iconScale,
      handler: function(){
        var sel = this.getSelectionModel().getSelections();
		if(sel.length == 1){
			var id = sel[0].get('id');
			alert(id);
		}else{
			//Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！');
			Ext.MessageBox.show({
				title:'温馨提示',
				msg: '只能选择一条记录，请重新选择！',
				buttons: Ext.MessageBox.OK,
				animEl: 'mb4',
				icon: Ext.MessageBox.INFO
			});
		}
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '新增',
      iconCls: 'icon-middle-cancel',
      scale: this.iconScale,
      handler: function(){
        
        var win = "";
		//添加建设单位	
	var Form = new Ext.FormPanel({
		id:'wgjlForm',
		labelAlign: 'right',
		height: 400,
		frame: true,
		plain: true,
		border: true,
		margins: '1 1 2 1',
		items: [{
			layout: 'column',
			items:[{
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'textfield',
					fieldLabel: '检查人',
					name: 'irCheckUser',
					emptyText:'',
					anchor: '100%'
				}]
			},{
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'datefield',
					fieldLabel: '检查时间',
					emptyText:'',
					name: 'irCheckTime',
					format:'Y-m-d',
					editable:false,
					anchor: '100%'
				}]
			},{				
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'textfield',
					fieldLabel: '登记人',
					emptyText:'',
					name: 'irInputUser',
					anchor: '100%'
				}]}]
		},{
			layout: 'column',
			items:[{
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'datefield',
					fieldLabel: '登记时间',
					emptyText:'',
					name: 'irInputTime',
					format:'Y-m-d',
					editable:false,
					anchor: '100%'
				}]
			},{
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'textfield',
					fieldLabel: '审批人',
					name: 'irAuditUser',
					emptyText:'',
					anchor: '100%'
				}]
			},{
				columnWidth: .33,
				layout: 'form',
				items: [{
					xtype: 'datefield',
					fieldLabel: '审批时间',
					emptyText:'',
					name: 'irAuditTime',
					format:'Y-m-d',
					editable:false,
					anchor: '100%'
				}]
			}]			
		},{
			layout: 'column',
			items:[{
				columnWidth: .99,
				layout: 'form',
				items: [{
					xtype: 'textarea',
					fieldLabel: '违规内容概述',
					emptyText:'',
					name: 'irDesc',
					anchor: '100%'
				}]		
			}]
		},
		{
				columnWidth: .3,
				layout: 'hbox',
				defaults:{margins:'20 5 0 50'},
				buttonAlign:'right',
				items:[{
					xtype: 'button',
					text: '&nbsp;确定',
					width: 80,
					iconCls: 'icon-find',
					handler: function(){
/*						Ext.Ajax.request({
							url:'/bo-traders-illegal-record!save.action',
							form:'Form',
							callback:function (options,success,response){
								//alert(response.responseText);
								alert("成功");
							}
						});						
						//this.grid.store.load();
						//this.searchForm.form.reset();
*/						
    					Form.form.submit({
    						url: 'yw-com-qyxx-csdlwj!save.action',
							waitMsg : '正在保存数据，请稍候...'
    					});
    					/*
    					Ext.MessageBox.show({
				           title:'温馨提示',
				           msg: '成功添加违规记录！',
				           buttons: Ext.MessageBox.OK,
				           animEl: 'mb4',
				           icon: Ext.MessageBox.INFO
				       	});
				       	*/
				       win.close();
    					//Ext.Msg.alert('系统提示', '成功添加违规记录！',function(){
    						//Form.hidden(true);
    					//	win.close();
    					//	grid.store.load();
    					//});
				}},{
					xtype: 'button',
					text: '清空',
					width: 80,
					handler: function(){
						Form.form.reset();
						grid.store.load();
					},
					scope: this
				},{
					xtype: 'button',
					text: '取消',
					width: 80,
					handler: function(){
						win.close();
					},
					scope: this
				}]
			}]
	});
		
					
					
						win = new Ext.Window({
							id        : 'attacheWin',
    						title     : '添加违规记录',
    						width     : 650,
							height    : 225,
							modal     : true,
							plain     : true,
							pageX	   : 30,
							pageY	   : 150,
							items     : Form
						}).show();
					
        this.search();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '关闭',
      iconCls: 'icon-middle-cancel',
      scale: this.iconScale,
      handler: function(){
        Ext.getCmp('selectJsdwWin').hide();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem('->');
    this.tbar.addItem('-');
       
    this.tbar.addItem('-');
  },
  printBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '查看文书',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
        this.printdblclick();
      },
      scope: this
    });
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '关闭',
      iconCls: 'icon-middle-cancel',
      scale: this.iconScale,
      handler: function(){
        window.close();
      },
      scope: this
    });
    this.tbar.addItem('-');
  },
  yslBtn: function () {
    this.tbar.addItem('->');
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '查看',
      iconCls: 'icon-user-edit',
      scale: this.iconScale,
      handler: function(){
        this.dblclick();
      },
      scope: this
    });
    this.tbar.addItem('-');
  },
  printRqjyxkzBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套打燃气经营许可证',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
      	openCenterWindow(ctx + '/yw-rq-qyjyxk!preViewJyxkz.action?id='+this.fkid, 1100, 650);
      },
      scope: this
    });
  },printRqjyxkzfbBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套打燃气经营许可证副本',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
        openCenterWindow(ctx + '/yw-rq-qyjyxk!preViewJyxkzfb.action?id='+this.fkid+'&templateCode=' + this.templateCode, 1100, 650);
      },
      scope: this
    });
  },
  printZzzsBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套打资质证书',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
        openCenterWindow(ctx + '/yw-rq-qyzz-info!preViewZzzs.action?id='+this.fkid, 1150, 650);
      },
      scope: this
    });
  },
  printZzzsfbBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套打资质证书副本',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
      	openCenterWindow(ctx + '/yw-rq-qyzz-info!preViewZzzsfb.action?id='+this.fkid, 1150, 650);
      },
      scope: this
    });
  },
  printHwggBtn: function () {
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套户外广告设置证',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
        openCenterWindow(ctx + '/yw-hw-sh-sqb!preViewHwgg.action?id='+this.fkid, 1150, 650);
      },
      scope: this
    });
  },
  printGyssxkbsBtn: function(){
    this.tbar.addItem('-');
    this.tbar.addItem({
      text: '套户燃气供应设施许可标识',
      iconCls: 'icon-print',
      scale: this.iconScale,
      handler: function(){
        openCenterWindow(ctx + '/yw-rq-qyjyxk!preViewGyssxkbs.action?id='+this.fkid, 1150, 650);
      },
      scope: this
    });
  }

});